<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <title><{$shop_data.shop_name}></title>
    <link href="/public/H-ui/css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link href="/public/H-ui/css/H-ui.admin.css" rel="stylesheet" type="text/css" />
    <link href="/public/H-ui/hui-iconfont/iconfont.css" rel="stylesheet" type="text/css">
</head>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 店铺管理 <span class="c-gray en">&gt;</span> 店铺设置 <a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="pd-20">
    <form action="<{site_url('/seller/system/setting/save')}>" method="post" class="form form-horizontal" id="save" enctype="multipart/form-data">
        <div id="tab-system" class="HuiTab">
            <div class="tabBar cl"><span>基本设置</span><span>BANNER设置</span></div>
            <!--基本设置-->
            <div class="tabCon">
                <div class="row cl">
                    <label class="form-label col-2"><span class="c-red">*</span>店铺名称：</label>
                    <div class="formControls col-3">
                        <input type="text" class="input-text" value="" name="shop_name" datatype="*" nullmsg="请输入店铺名称！">
                    </div>
                </div>
                <div class="row cl">
                    <label class="form-label col-2"><span class="c-red">*</span>店铺logo：</label>
                    <div class="formControls col-3">
                        <a href="<{$item.logo}>" target="_blank"><img src="<{$item.logo}>" width="50" <{if $item.logo==''}>style="display: none;"<{/if}>></a>
                        <input type="hidden" value="" name="logo" datatype="*" nullmsg="请上传店铺logo！">
                        <input type="file" name="logo_pic" id="logo_pic" onchange="upload_file(this);" style="width: 150px;">
                    </div>
                </div>
                <div class="row cl">
                    <label class="form-label col-2"><span class="c-red">*</span>电话：</label>
                    <div class="formControls col-3">
                        <input type="text" class="input-text" value="" name="tel" datatype="*" nullmsg="请输入店铺名称！">
                    </div>
                </div>
                <div class="row cl">
                    <label class="form-label col-2"><span class="c-red">*</span>邮箱：</label>
                    <div class="formControls col-3">
                        <input type="text" class="input-text" value="" name="email" datatype="e" errormsg="邮箱格式错误！">
                    </div>
                </div>
                <div class="row cl">
                    <label class="form-label col-2">第三方客服链接：</label>
                    <div class="formControls col-3">
                        <input type="text" class="input-text" value="" name="customer_url" datatype="empty|url" nullmsg="第三方客服链接！">
                    </div>
                </div>
                <div class="row cl">
                    <label class="form-label col-2"><span class="c-red">*</span>营业执照：</label>
                    <div class="formControls col-3">
                        <a href="<{$item.business_license}>" target="_blank"><img src="<{$item.business_license}>" width="50" <{if $item.business_license==''}>style="display: none;"<{/if}>></a>
                        <{if $item.status==2}>
                        <input type="hidden" value="" name="business_license" datatype="*" nullmsg="请上传营业执照">
                        <input type="file" name="business_license_pic" id="business_license_pic" onchange="upload_file(this);" style="width: 150px;">
                        <{/if}>
                    </div>
                </div>
                <div class="row cl">
                    <label class="form-label col-2"><span class="c-red">*</span>省市区：</label>
                    <div class="formControls col-5">
                        <span class="select-box" style="width: 31%;">
                        <select name="prov" class="select" onchange="area_list('city',this.value);" datatype="*" nullmsg="请选择省！">
                        </select>
                        </span>
                        <span class="select-box" style="width: 31%;">
                        <select name="city" class="select" onchange="area_list('area',this.value);" datatype="*" nullmsg="请选择市！">
                            <option>请选择市</option>
                        </select>
                        </span>
                        <span class="select-box" style="width: 31%;">
                        <select name="area" class="select" datatype="*" nullmsg="请选择区！">
                            <option>请选择区</option>
                        </select>
                        </span>
                    </div>
                </div>
                <div class="row cl">
                    <label class="form-label col-2"><span class="c-red">*</span>地址：</label>
                    <div class="formControls col-3">
                        <input type="text" class="input-text" value="" name="address" datatype="*" nullmsg="请输入地址！">
                    </div>
                </div>
                <div class="row cl">
                    <label class="form-label col-2"><span class="c-red">*</span>店铺简介：</label>
                    <div class="formControls col-6">
                        <textarea name="desc" cols="" rows="" class="textarea"  placeholder="店铺简介" datatype="*1-100" dragonfly="true" nullmsg="店铺简介不能为空！" onKeyUp="textarealength(this,100)"></textarea>
                        <p class="textarea-numberbar"><em class="textarea-length">0</em>/100</p>
                    </div>
                </div>
            </div>
            <!--显示设置-->
            <div class="tabCon">
                <table class="mt-10 table table-border table-bordered table-bg table-hover table-sort">
                    <thead>
                    <tr class="text-c">
                        <th width="150">名称</th>
                        <th width="200">连接地址</th>
                        <th>图片</th>
                        <th width="80">操作</th>
                    </tr>
                    </thead>
                    <tbody id="banner_list">

                    </tbody>
                </table>
                <!--属性模板-->
                <script type='text/html' id='banner_list_Template'>
                    {{each banner_url}}
                    <tr class="text-c">
                        <td>
                            <input type="text" class="input-text" value="{{$value.name}}" name="banner_name[]">
                        </td>
                        <td>
                            <input type="text" class="input-text" value="{{$value.link}}" name="banner_link[]">
                        </td>
                        <td class="text-l">
                            <a href="{{$value.url}}" target="_blank"><img src="{{$value.url}}" height="50" {{if $value.url==''}}style="display: none;"{{/if}}></a>
                            <input type="hidden" value="{{$value.url}}" name="banner_url[]">
                            <input type="file" name="banner_url_pic_{{$index}}" id="banner_url_pic_{{$index}}" onchange="upload_file(this);" style="width: 150px;">
                        </td>
                        <td class="f-14">
                            <a onclick="up_tr(this);"><i class="Hui-iconfont">&#xe679;</i></a>
                            <a onclick="down_tr(this);"><i class="Hui-iconfont">&#xe674;</i></a>
                            <a onclick="$(this).parent().parent().remove();"><i class="Hui-iconfont">&#xe609;</i></a>
                        </td>
                    </tr>
                    {{/each}}
                </script>
                <div class="row cl">
                    <div class="col-10 col-offset-2">
                        <button onClick="banner_list_tmp();" class="btn btn-primary radius" type="button"><i class="Hui-iconfont">&#xe632;</i> 添加banner</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="row cl">
            <div class="col-10 col-offset-2">
                <button onClick="$('#add').submit();" class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存</button>
                <button onClick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript" src="/public/js/jquery.js"></script>
<script type="text/javascript" src="/public/js/validform.js"></script>
<script type="text/javascript" src="/public/js/layer/layer.js"></script>
<script type="text/javascript" src="/public/js/form.js"></script>
<script type="text/javascript" src="/public/js/artTemplate.js"></script>
<script type="text/javascript" src="/public/js/icheck/jquery.icheck.min.js"></script>
<script type="text/javascript" src="/public/H-ui/js/H-ui.js"></script>
<script type="text/javascript" src="/public/H-ui/js/H-ui.admin.js"></script>
<{ajax_upload()}>
<script type="text/javascript">
    $(function() {
        //验证表单
        $.Tipmsg.r = null;
        $("#save").Validform({
            tiptype: function (msg) {
                layer.msg(msg);
            },
            tipSweep: true,
            ajaxPost: true,
            callback: function (data) {
                if (data.status == "y") {
                    window.location.reload();
                }
            }
        });

        //表单回填
        var formObj = new Form();
        formObj.init(<{ch_json_encode($item)}>);

        <{if $item.banner_url!=''}>
            banner_list_tmp(<{ch_json_encode($item)}>);//属性回填
        <{/if}>
    })

    //添加图片展示
    function show_upload(spec_pic, url){
        $("#"+spec_pic).parent().find('img').attr('src',url);
        $("#"+spec_pic).parent().find('img').show();
        $("#"+spec_pic).parent().find('a').attr('href',url);
        $("#"+spec_pic).parent().find('[type="hidden"]').val(url);
    }

    //banner模板解析
    function banner_list_tmp(data){
        var data = arguments[0] ? arguments[0] :'';
        if(data=='')
        {
            data = {"banner_url":[{"name":"","link":"","url":""}]};
        }
        var html = template('banner_list_Template', data);
        $('#banner_list').append(html);
    }

    //向上移动
    function up_tr(obj){
        var insertIndex = $(obj).parent().parent().prev().index();
        if(insertIndex >= 0)
        {
            $('#banner_list tr:eq('+insertIndex+')').before($(obj).parent().parent());
        }
    }

    //向下移动
    function down_tr(obj){
        var insertIndex = $(obj).parent().parent().next().index();
        $('#banner_list tr:eq('+insertIndex+')').after($(obj).parent().parent());
    }

    //菜单切换
    $(function(){
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });
        $.Huitab("#tab-system .tabBar span","#tab-system .tabCon","current","click","0");
    });

    //地区加载area_type 选择框名称 parent_id 上级id default_id默认id
    function area_list(area_type, parent_id, default_id){
        $.ajax({
            type:"POST",
            url: '<{site_url("/api/area/get_list")}>',
            data: 'parent_id='+parent_id+'&default_id='+default_id,
            dataType:"html",
            success: function(data){
                $('[name="'+area_type+'"]').html(data);
            }
        });
    }

    //省市区回填
    area_list('prov', 0 <{if $item.prov!=''}>,<{$item.prov}><{/if}>);//省份选择
    <{if $item.city!='' && $item.prov!=''}>
    area_list('city', <{$item.prov}>, <{$item.city}>);//市
    <{/if}>
    <{if $item.area!='' && $item.city!=''}>
    area_list('area', <{$item.city}>, <{$item.area}>);//区
    <{/if}>
</script>
</body>
</html>